package com.grass.appointment.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.View;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.ViewPager;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.bean.UserInfo;
import com.androidx.p013lv.base.bean.event.AttentionPhoenixEvent;
import com.androidx.p013lv.base.dialog.ProgressBarDialog;
import com.androidx.p013lv.base.http.BaseRes;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.p015ui.BaseActivity;
import com.androidx.p013lv.base.utils.GlideEngine;
import com.androidx.p013lv.base.utils.NetUtil;
import com.androidx.p013lv.base.utils.PictureStyle;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.ToastUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.grass.appointment.C2694R;
import com.grass.appointment.adapter.CheckBannerAdapter;
import com.grass.appointment.bean.CoverBean;
import com.grass.appointment.bean.UploadImgBean;
import com.grass.appointment.databinding.ActivityUserInfoLayoutBinding;
import com.grass.appointment.databinding.FragmentAppointmentDynamicBinding;
import com.grass.appointment.dialog.RewardDialog;
import com.grass.appointment.dialog.SelectPicDialog;
import com.grass.appointment.dialog.UnLockDialog;
import com.grass.appointment.fragment.DataAppointmentFragment;
import com.grass.appointment.fragment.DynamicAppointmentFragment;
import com.grass.appointment.model.SaveCoverModel;
import com.grass.appointment.model.UserPhoenixModel;
import com.gyf.immersionbar.ImmersionBar;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.broadcast.BroadcastAction;
import com.luck.picture.lib.broadcast.BroadcastManager;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.listener.OnResultCallbackListener;
import com.luck.picture.lib.permissions.PermissionChecker;
import com.luck.picture.lib.style.PictureParameterStyle;
import com.luck.picture.lib.tools.PictureFileUtils;
import com.youth.banner.indicator.RectangleIndicator;
import com.youth.banner.listener.OnBannerListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import org.greenrobot.eventbus.EventBus;
import p000a.p002b.RxPermissions;
import p023io.reactivex.functions.Consumer;

public class UserInfoActivity extends BaseActivity<ActivityUserInfoLayoutBinding> implements UnLockDialog.UnlockInterface {
    private static final int maxNum = 6;
    private FragmentStatePagerAdapter adapter;
    private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
        /* class com.grass.appointment.activity.UserInfoActivity.C27301 */

        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action != null && BroadcastAction.ACTION_DELETE_PREVIEW_POSITION.equals(action)) {
                Bundle extras = intent.getExtras();
                int i = 0;
                if (extras != null) {
                    i = extras.getInt("position");
                }
                if (i < UserInfoActivity.this.coverList.size()) {
                    UserInfoActivity.this.coverModel.deleteCover(((CoverBean) UserInfoActivity.this.coverList.get(i)).getUrl());
                    UserInfoActivity.this.coverList.remove(i);
                    if (UserInfoActivity.this.coverList.size() == 0) {
                        UserInfoActivity.this.initDefaultCover();
                    } else {
                        ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).include.banner.setDatas(UserInfoActivity.this.coverList);
                    }
                }
            }
        }
    };
    private OnClick click;
    private List<CoverBean> coverList;
    private SaveCoverModel coverModel;
    private SelectPicDialog dialog;
    private SparseArray<Fragment> fragments = new SparseArray<>();
    private boolean isSelf = false;
    private ProgressBarDialog loading;
    private UserPhoenixModel model;
    private int playType;
    private PopupWindow popupWindow;
    private List<String> tabTitles;
    public int type;
    private UnLockDialog unLockDialog;
    private List<String> uploadCover;
    private int uploadNum;
    public int userId;
    private UserInfo userInfo;

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(((ActivityUserInfoLayoutBinding) this.binding).toolBar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public int setLayout() {
        return C2694R.C2699layout.activity_user_info_layout;
    }

    /* access modifiers changed from: protected */
    @Override // com.androidx.p013lv.base.p015ui.BaseActivity
    public void initView() {
        super.initView();
        this.coverList = new ArrayList();
        this.tabTitles = new ArrayList();
        this.uploadCover = new ArrayList();
        this.model = (UserPhoenixModel) new ViewModelProvider(this).get(UserPhoenixModel.class);
        this.coverModel = (SaveCoverModel) new ViewModelProvider(this).get(SaveCoverModel.class);
        ((ActivityUserInfoLayoutBinding) this.binding).setFameStatus(0);
        this.click = new OnClick();
        ((ActivityUserInfoLayoutBinding) this.binding).setClick(this.click);
        ((ActivityUserInfoLayoutBinding) this.binding).include.getRoot().measure(0, 0);
        final int screenWidth = UiUtils.getScreenWidth() - (ImmersionBar.getActionBarHeight(this) + ImmersionBar.getStatusBarHeight(this));
        ((ActivityUserInfoLayoutBinding) this.binding).appBar.addOnOffsetChangedListener((AppBarLayout.OnOffsetChangedListener) new AppBarLayout.OnOffsetChangedListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27412 */

            @Override // com.google.android.material.appbar.AppBarLayout.BaseOnOffsetChangedListener, com.google.android.material.appbar.AppBarLayout.OnOffsetChangedListener
            public void onOffsetChanged(AppBarLayout appBarLayout, int i) {
                ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).toolBar.getBackground().setAlpha((int) (Math.min((((float) Math.abs(i)) * 1.0f) / ((float) screenWidth), 1.0f) * 255.0f));
            }
        });
        if (this.userId == SpUtils.getInstance().getUserInfo().getUserId()) {
            this.isSelf = true;
        }
        initTabLayout();
        initViewPager();
        initPopupWindow();
        CoverBean coverBean = new CoverBean();
        coverBean.setUrl(Key.IC_APPOINTMENT_DEFAULT);
        this.coverList.add(coverBean);
        ((ActivityUserInfoLayoutBinding) this.binding).include.banner.setIndicator(new RectangleIndicator(this));
        ((ActivityUserInfoLayoutBinding) this.binding).include.banner.setAdapter(new CheckBannerAdapter(this.coverList, SpUtils.getInstance().getString("domain"), this.isSelf));
        ((ActivityUserInfoLayoutBinding) this.binding).viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27433 */

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageScrollStateChanged(int i) {
            }

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageScrolled(int i, float f, int i2) {
            }

            @Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
            public void onPageSelected(int i) {
                if (UserInfoActivity.this.isSelf && i == 1 && ((FragmentAppointmentDynamicBinding) ((DynamicAppointmentFragment) UserInfoActivity.this.fragments.get(i)).binding).getStatus().intValue() == 0) {
                    ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).setStatus(1);
                } else {
                    ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).setStatus(0);
                }
            }
        });
        this.model.operationInfo().observe(this, new Observer<BaseRes<UserInfo>>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27444 */

            public void onChanged(BaseRes<UserInfo> baseRes) {
                if (baseRes.getCode() == 200) {
                    UserInfoActivity.this.userInfo = baseRes.getData();
                    ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).setUserInfo(UserInfoActivity.this.userInfo);
                    UserInfoActivity.this.tabTitles.clear();
                    UserInfoActivity.this.tabTitles.add("資料");
                    List list = UserInfoActivity.this.tabTitles;
                    list.add("動態 " + UserInfoActivity.this.userInfo.getDynamicNum());
                    UserInfoActivity.this.adapter.notifyDataSetChanged();
                    UserInfoActivity.this.coverList.clear();
                    UserInfoActivity userInfoActivity = UserInfoActivity.this;
                    userInfoActivity.notifyBannerData(userInfoActivity.userInfo);
                    return;
                }
                ToastUtils.getInstance().showWrong(baseRes.getMsg());
            }
        });
        this.model.dataAboutHer().observe(this, new Observer<BaseRes<String>>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27455 */

            public void onChanged(BaseRes<String> baseRes) {
                if (baseRes.getCode() == 200) {
                    if (UserInfoActivity.this.userInfo != null) {
                        UserInfoActivity.this.userInfo.setMeetLock(true);
                        ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).setUserInfo(UserInfoActivity.this.userInfo);
                        ToastUtils.getInstance().showCorrect("恭喜！解鎖成功");
                        return;
                    }
                    ToastUtils.getInstance().showSigh("用戶信息異常!");
                }
                ToastUtils.getInstance().showWrong(baseRes.getMsg());
            }
        });
        this.model.rewardHer().observe(this, new Observer<BaseRes<String>>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27466 */

            public void onChanged(BaseRes<String> baseRes) {
                if (baseRes.getCode() == 200) {
                    ToastUtils.getInstance().showCorrect("打賞成功，感謝支持");
                } else {
                    ToastUtils.getInstance().showWrong(baseRes.getMsg());
                }
            }
        });
        this.coverModel.imageData().observe(this, new Observer<BaseRes<UploadImgBean>>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27477 */

            public void onChanged(BaseRes<UploadImgBean> baseRes) {
                if (baseRes.getCode() == 100) {
                    UserInfoActivity.this.showProgressBarDialog("正在保存，請稍後");
                    UserInfoActivity.this.coverModel.saveCover(UserInfoActivity.this.uploadCover);
                    UserInfoActivity.this.uploadNum += UserInfoActivity.this.uploadCover.size();
                } else if (baseRes.getCode() == 200) {
                    UserInfoActivity.this.uploadCover.add(baseRes.getData().getFileName());
                    UserInfoActivity.this.showProgressBarDialog("正在上傳, 已完成" + UserInfoActivity.this.uploadCover.size() + "張");
                } else {
                    ToastUtils.getInstance().showWrong("上傳失败");
                    UserInfoActivity.this.dismissProgressBarDialog();
                }
            }
        });
        this.coverModel.getSaveCover().observe(this, new Observer<BaseRes>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27488 */

            public void onChanged(BaseRes baseRes) {
                UserInfoActivity.this.dismissProgressBarDialog();
                if (baseRes.getCode() == 200) {
                    ToastUtils.getInstance().showCorrect("上傳成功,請耐心等待審核");
                    UserInfoActivity.this.initUploadSuccess();
                    return;
                }
                ToastUtils.getInstance().showWrong("上傳失败");
            }
        });
        this.coverModel.getDeleteCover().observe(this, new Observer<BaseRes>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C27499 */

            public void onChanged(BaseRes baseRes) {
                if (baseRes.getCode() == 200) {
                    ToastUtils.getInstance().showCorrect("刪除成功");
                } else {
                    ToastUtils.getInstance().showWrong(baseRes.getMsg());
                }
            }
        });
        this.model.getAction().observe(this, new Observer<Integer>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C273110 */

            public void onChanged(Integer num) {
                if (num.intValue() == 10000001) {
                    UserInfoActivity.this.click.btnUnlockNow();
                }
            }
        });
        this.model.getOperationInfo(this, this.userId);
    }

    private void initViewPager() {
        this.tabTitles.clear();
        this.tabTitles.add("資料");
        this.fragments.append(0, DataAppointmentFragment.newInstance(this.userId));
        this.tabTitles.add("動態");
        this.fragments.append(1, DynamicAppointmentFragment.newInstance(this.userId));
        this.adapter = new Adapter(getSupportFragmentManager());
        ((ActivityUserInfoLayoutBinding) this.binding).viewPager.setAdapter(this.adapter);
        ((ActivityUserInfoLayoutBinding) this.binding).viewPager.setOffscreenPageLimit(2);
        if (this.type == -1) {
            ((ActivityUserInfoLayoutBinding) this.binding).viewPager.setCurrentItem(0);
        } else {
            ((ActivityUserInfoLayoutBinding) this.binding).viewPager.setCurrentItem(this.type);
        }
        ((ActivityUserInfoLayoutBinding) this.binding).tabLayout.setupWithViewPager(((ActivityUserInfoLayoutBinding) this.binding).viewPager);
        ((ActivityUserInfoLayoutBinding) this.binding).setIsSelf(Boolean.valueOf(this.isSelf));
    }

    private void initPopupWindow() {
        View inflate = View.inflate(this, C2694R.C2699layout.picture_popup_window, null);
        inflate.findViewById(C2694R.C2697id.tv_out_btn).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.View$OnClickListenerC273211 */

            public void onClick(View view) {
                UserInfoActivity.this.popupWindow.dismiss();
            }
        });
        inflate.findViewById(C2694R.C2697id.tv_camera_btn).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.View$OnClickListenerC273312 */

            public void onClick(View view) {
                UserInfoActivity.this.popupWindow.dismiss();
                UserInfoActivity.this.requestCameraPermission();
            }
        });
        inflate.findViewById(C2694R.C2697id.tv_picture_btn).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.View$OnClickListenerC273413 */

            public void onClick(View view) {
                UserInfoActivity.this.popupWindow.dismiss();
                if (6 - UserInfoActivity.this.uploadNum <= 0) {
                    ToastUtils.getInstance().showSigh("最多上傳6張封面");
                    return;
                }
                UserInfoActivity userInfoActivity = UserInfoActivity.this;
                userInfoActivity.requestPicturePermission(6 - userInfoActivity.uploadNum);
            }
        });
        inflate.findViewById(C2694R.C2697id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.View$OnClickListenerC273514 */

            public void onClick(View view) {
                UserInfoActivity.this.popupWindow.dismiss();
            }
        });
        PopupWindow popupWindow2 = new PopupWindow(inflate, -1, -1);
        this.popupWindow = popupWindow2;
        popupWindow2.setOutsideTouchable(true);
        this.popupWindow.setBackgroundDrawable(new ColorDrawable());
        this.popupWindow.setAnimationStyle(C2694R.C2701style.PopAnimation);
    }

    private void initTabLayout() {
        ((ActivityUserInfoLayoutBinding) this.binding).tabLayout.addOnTabSelectedListener((TabLayout.OnTabSelectedListener) new TabLayout.OnTabSelectedListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.C273615 */

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabReselected(TabLayout.Tab tab) {
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabSelected(TabLayout.Tab tab) {
                UserInfoActivity.this.changeTabTextView(tab, true);
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabUnselected(TabLayout.Tab tab) {
                UserInfoActivity.this.changeTabTextView(tab, false);
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void changeTabTextView(TabLayout.Tab tab, boolean z) {
        if (tab.getCustomView() == null) {
            tab.setCustomView(C2694R.C2699layout.appointment_tab_layout);
        }
        TextView textView = (TextView) tab.getCustomView().findViewById(16908308);
        if (z) {
            textView.setTextAppearance(this, C2694R.C2701style.TabLayoutAttentionTextSize);
        } else {
            textView.setTextAppearance(this, C2694R.C2701style.TabLayoutNormalAttentionTextSize);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void notifyBannerData(UserInfo userInfo2) {
        List<String> bgImgs = userInfo2.getBgImgs();
        List<UserInfo.UserBgImgCheck> checkImgs = userInfo2.getCheckImgs();
        if (bgImgs != null && bgImgs.size() > 0) {
            for (String str : bgImgs) {
                CoverBean coverBean = new CoverBean();
                coverBean.setStatus(2);
                coverBean.setUrl(str);
                this.coverList.add(coverBean);
            }
        }
        if (checkImgs != null && checkImgs.size() > 0) {
            for (UserInfo.UserBgImgCheck userBgImgCheck : checkImgs) {
                for (String str2 : userBgImgCheck.getBgImgs()) {
                    CoverBean coverBean2 = new CoverBean();
                    coverBean2.setStatus(userBgImgCheck.getStatus());
                    coverBean2.setUrl(str2);
                    this.coverList.add(coverBean2);
                }
            }
        }
        this.uploadNum = this.coverList.size();
        if (this.coverList.size() > 0) {
            initBannerData(this.coverList);
        } else {
            initDefaultCover();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void initDefaultCover() {
        CoverBean coverBean = new CoverBean();
        coverBean.setUrl(Key.IC_APPOINTMENT_DEFAULT);
        this.coverList.add(coverBean);
        ((ActivityUserInfoLayoutBinding) this.binding).include.banner.setDatas(this.coverList);
    }

    /* access modifiers changed from: protected */
    @Override // androidx.fragment.app.FragmentActivity
    public void onResume() {
        if (this.isSelf) {
            ((ActivityUserInfoLayoutBinding) this.binding).setUserInfo(SpUtils.getInstance().getUserInfo());
        }
        super.onResume();
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void initUploadSuccess() {
        Iterator<CoverBean> it = this.coverList.iterator();
        while (it.hasNext()) {
            if (it.next().getUrl().equals(Key.IC_APPOINTMENT_DEFAULT)) {
                it.remove();
            }
        }
        for (String str : this.uploadCover) {
            CoverBean coverBean = new CoverBean();
            coverBean.setStatus(1);
            coverBean.setUrl(str);
            this.coverList.add(coverBean);
        }
        ((ActivityUserInfoLayoutBinding) this.binding).include.banner.setDatas(this.coverList);
        this.uploadCover.clear();
    }

    private void initBannerData(final List<CoverBean> list) {
        ((ActivityUserInfoLayoutBinding) this.binding).include.banner.setDatas(list);
        ((ActivityUserInfoLayoutBinding) this.binding).include.banner.setOnBannerListener(new OnBannerListener() {
            /* class com.grass.appointment.activity.UserInfoActivity.C273716 */

            @Override // com.youth.banner.listener.OnBannerListener
            public void OnBannerClick(Object obj, int i) {
                ArrayList arrayList = new ArrayList();
                Iterator it = list.iterator();
                while (it.hasNext()) {
                    LocalMedia localMedia = new LocalMedia();
                    localMedia.setPath(SpUtils.getInstance().getString("domain") + ((CoverBean) it.next()).getUrl());
                    arrayList.add(localMedia);
                }
                PictureParameterStyle picturePreviewStyle = PictureStyle.getInstance(UserInfoActivity.this).getPicturePreviewStyle();
                picturePreviewStyle.f1970a = UserInfoActivity.this.isSelf;
                PictureSelector.create(UserInfoActivity.this).setPictureStyle(picturePreviewStyle).isNotPreviewDownload(false).imageEngine(GlideEngine.createGlideEngine()).openExternalPreview(i, arrayList);
            }
        });
        if (this.isSelf) {
            BroadcastManager.getInstance(this).registerReceiver(this.broadcastReceiver, BroadcastAction.ACTION_DELETE_PREVIEW_POSITION);
        }
    }

    public static void setUserSexDetails(ImageView imageView, int i) {
        if (i == 1) {
            imageView.setImageResource(C2694R.C2696drawable.ic_girl);
        } else if (i == 2) {
            imageView.setImageResource(C2694R.C2696drawable.ic_man);
        } else {
            imageView.setImageResource(C2694R.C2696drawable.ic_man_girl);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void requestPicturePermission(final int i) {
        if (Build.VERSION.SDK_INT >= 23) {
            new RxPermissions(this).request("android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").subscribe(new Consumer<Boolean>() {
                /* class com.grass.appointment.activity.UserInfoActivity.C273817 */

                public void accept(Boolean bool) throws Exception {
                    if (bool.booleanValue()) {
                        UserInfoActivity.this.selectPicture(i);
                    } else {
                        ToastUtils.getInstance().showSigh("未授權權限，請在設置中允許權限");
                    }
                }
            });
        } else {
            selectPicture(i);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void requestCameraPermission() {
        if (Build.VERSION.SDK_INT >= 23) {
            new RxPermissions(this).request("android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").subscribe(new Consumer<Boolean>() {
                /* class com.grass.appointment.activity.UserInfoActivity.C273918 */

                public void accept(Boolean bool) throws Exception {
                    if (bool.booleanValue()) {
                        UserInfoActivity.this.openCamera();
                    } else {
                        ToastUtils.getInstance().showSigh("未授權權限，請在設置中允許權限");
                    }
                }
            });
        } else {
            openCamera();
        }
    }

    private void clearCache() {
        if (PermissionChecker.checkSelfPermission((Context) Objects.requireNonNull(getActivity()), "android.permission.WRITE_EXTERNAL_STORAGE")) {
            PictureFileUtils.deleteAllCacheDirFile(getActivity());
        } else {
            PermissionChecker.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void selectPicture(int i) {
        PictureSelector.create(this).openGallery(PictureMimeType.ofImage()).imageEngine(GlideEngine.createGlideEngine()).selectionMode(2).setPictureStyle(PictureStyle.getInstance(getActivity()).getPictureParameterStyle()).setPictureCropStyle(PictureStyle.getInstance(getActivity()).getCropParameterStyle()).maxSelectNum(i).isPreviewImage(true).isCamera(true).isEnableCrop(true).rotateEnabled(false).circleDimmedLayer(false).showCropFrame(true).showCropGrid(true).scaleEnabled(true).isDragFrame(false).withAspectRatio(1, 1).freeStyleCropEnabled(true).forResult(new OnResultCallbackListener<LocalMedia>() {
            /* class com.grass.appointment.activity.UserInfoActivity.C274019 */

            @Override // com.luck.picture.lib.listener.OnResultCallbackListener
            public void onCancel() {
            }

            @Override // com.luck.picture.lib.listener.OnResultCallbackListener
            public void onResult(List<LocalMedia> list) {
                if (list != null && list.size() > 0) {
                    UserInfoActivity.this.showProgressBarDialog("正在上傳，請稍後");
                    ArrayList arrayList = new ArrayList();
                    for (LocalMedia localMedia : list) {
                        arrayList.add(localMedia.getCutPath());
                    }
                    UserInfoActivity.this.coverModel.upLoadImageCover(arrayList);
                }
            }
        });
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void openCamera() {
        if (6 - this.uploadNum <= 0) {
            ToastUtils.getInstance().showSigh("最多上傳6張封面");
        } else {
            PictureSelector.create(this).openCamera(PictureMimeType.ofImage()).imageEngine(GlideEngine.createGlideEngine()).selectionMode(1).setPictureStyle(PictureStyle.getInstance(getActivity()).getPictureParameterStyle()).setPictureCropStyle(PictureStyle.getInstance(getActivity()).getCropParameterStyle()).isPreviewImage(true).isEnableCrop(true).rotateEnabled(false).circleDimmedLayer(false).showCropFrame(true).showCropGrid(true).scaleEnabled(true).isDragFrame(false).withAspectRatio(1, 1).freeStyleCropEnabled(true).forResult(new OnResultCallbackListener<LocalMedia>() {
                /* class com.grass.appointment.activity.UserInfoActivity.C274220 */

                @Override // com.luck.picture.lib.listener.OnResultCallbackListener
                public void onCancel() {
                }

                @Override // com.luck.picture.lib.listener.OnResultCallbackListener
                public void onResult(List<LocalMedia> list) {
                    if (list != null && list.size() > 0) {
                        UserInfoActivity.this.showProgressBarDialog("正在上傳，請稍後");
                        ArrayList arrayList = new ArrayList();
                        for (LocalMedia localMedia : list) {
                            arrayList.add(localMedia.getCutPath());
                        }
                        UserInfoActivity.this.coverModel.upLoadImageCover(arrayList);
                    }
                }
            });
        }
    }

    @Override // com.grass.appointment.dialog.UnLockDialog.UnlockInterface
    public void onCommitClick() {
        if (this.playType == 0) {
            ARouter.getInstance().build(Constance.VIP_CENTER_ACTIVITY).withInt("type", 1).withString(Key.BACK_TITLE, "樓鳳").navigation();
        } else {
            this.model.meetLock(this, this.userId);
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void dismissProgressBarDialog() {
        ProgressBarDialog progressBarDialog = this.loading;
        if (progressBarDialog != null && progressBarDialog.isShowing()) {
            this.loading.dismiss();
        }
    }

    /* access modifiers changed from: private */
    /* access modifiers changed from: public */
    private void showProgressBarDialog(String str) {
        if (this.loading == null) {
            this.loading = new ProgressBarDialog(this);
        }
        this.loading.setHint(str);
        if (!this.loading.isShowing()) {
            this.loading.show();
        }
    }

    public void clickReward(int i, String str) {
        if (i > SpUtils.getInstance().getUserAccount().getGold()) {
            ToastUtils.getInstance().showSigh("余額不足，請充值");
            ARouter.getInstance().build(Constance.VIP_CENTER_ACTIVITY).withInt("type", 1).withString(Key.BACK_TITLE, "樓鳳").navigation();
            return;
        }
        this.model.rewardNow(this, this.userInfo.getUserId(), i, str);
    }

    /* access modifiers changed from: package-private */
    public class Adapter extends FragmentStatePagerAdapter {
        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return 2;
        }

        private Adapter(FragmentManager fragmentManager) {
            super(fragmentManager, 1);
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            return (Fragment) UserInfoActivity.this.fragments.get(i);
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return (CharSequence) UserInfoActivity.this.tabTitles.get(i);
        }
    }

    public class OnClick {
        public OnClick() {
        }

        public void btnBack() {
            UserInfoActivity.this.finish();
        }

        public void btnFollowClick() {
            if (!UserInfoActivity.this.isOnClick()) {
                if (!NetUtil.isNetworkAvailable()) {
                    ToastUtils.getInstance().showWrong(UiUtils.getString(C2694R.string.hit_no_net));
                } else if (UserInfoActivity.this.userInfo != null) {
                    int i = 1;
                    boolean z = !UserInfoActivity.this.userInfo.isAttentionHe();
                    UserInfoActivity.this.model.isFollowUser(UserInfoActivity.this.userInfo.getUserId(), z);
                    if (!z) {
                        i = -1;
                    }
                    UserInfoActivity.this.userInfo.setBu(UserInfoActivity.this.userInfo.getBu() + i);
                    UserInfoActivity.this.userInfo.setAttentionHe(z);
                    ((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).setUserInfo(UserInfoActivity.this.userInfo);
                    EventBus.getDefault().post(new AttentionPhoenixEvent(UserInfoActivity.this.userInfo.getUserId(), z));
                }
            }
        }

        public void showPopupWindow() {
            if (!UserInfoActivity.this.isOnClick()) {
                UserInfoActivity.this.popupWindow.showAtLocation(((ActivityUserInfoLayoutBinding) UserInfoActivity.this.binding).rootView, 17, 0, 0);
            }
        }

        public void btnUnlockNow() {
            if (UserInfoActivity.this.isOnClick() || UserInfoActivity.this.userInfo == null) {
                return;
            }
            if (UserInfoActivity.this.userInfo.isOfficial()) {
                ARouter.getInstance().build(Constance.VIP_CENTER_ACTIVITY).withInt("type", 2).withString(Key.BACK_TITLE, "樓鳳").navigation();
                return;
            }
            UserInfoActivity userInfoActivity = UserInfoActivity.this;
            userInfoActivity.unLockDialog = UnLockDialog.newInstance(UserInfoActivity.this.userInfo.getMeetPrice() + "");
            UserInfoActivity.this.unLockDialog.setUnlockInterface(UserInfoActivity.this);
            if (UserInfoActivity.this.userInfo.getMeetPrice() > SpUtils.getInstance().getUserAccount().getGold()) {
                UserInfoActivity.this.playType = 0;
                UserInfoActivity.this.unLockDialog.setContent("金幣不足哦，請先購買金幣!", "購買金幣");
            } else {
                UserInfoActivity.this.playType = 1;
                UserInfoActivity.this.unLockDialog.setContent("解鎖該聯系方式需支付", "確定");
            }
            UserInfoActivity.this.unLockDialog.show(UserInfoActivity.this.getSupportFragmentManager(), "unLockDialog");
        }

        public void btnReward() {
            if (!UserInfoActivity.this.isOnClick() && UserInfoActivity.this.userInfo != null) {
                RewardDialog newInstance = RewardDialog.newInstance();
                newInstance.setRewardInterface(new RewardDialog.RewardInterface() {
                    /* class com.grass.appointment.activity.UserInfoActivity.OnClick.C27501 */

                    @Override // com.grass.appointment.dialog.RewardDialog.RewardInterface
                    public void onClickReward(int i, String str) {
                        UserInfoActivity.this.clickReward(i, str);
                    }
                });
                newInstance.show(UserInfoActivity.this.getSupportFragmentManager(), "reward");
            }
        }

        public void editUserDetails() {
            if (!UserInfoActivity.this.isOnClick()) {
                ARouter.getInstance().build(Constance.EDIT_USER_INFO_ACTIVITY).navigation();
            }
        }

        public void goSendDynamic() {
            if (!UserInfoActivity.this.isOnClick()) {
                if (UserInfoActivity.this.dialog == null) {
                    UserInfoActivity.this.dialog = new SelectPicDialog(UserInfoActivity.this, new View.OnClickListener() {
                        /* class com.grass.appointment.activity.UserInfoActivity.OnClick.View$OnClickListenerC27512 */

                        public void onClick(View view) {
                            UserInfoActivity.this.dialog.dismiss();
                            if (view.getId() == C2694R.C2697id.ll_video) {
                                ARouter.getInstance().build(Constance.SEND_DYNAMIC_ACTIVITY).withInt("type", 1).navigation();
                            } else if (view.getId() == C2694R.C2697id.ll_pic) {
                                ARouter.getInstance().build(Constance.SEND_DYNAMIC_ACTIVITY).withInt("type", 0).navigation();
                            }
                        }
                    });
                }
                UserInfoActivity.this.dialog.show();
            }
        }
    }

    /* access modifiers changed from: protected */
    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, com.androidx.p013lv.base.p015ui.BaseActivity
    public void onDestroy() {
        UserPhoenixModel userPhoenixModel = this.model;
        if (userPhoenixModel != null) {
            userPhoenixModel.cancelHttp();
        }
        SaveCoverModel saveCoverModel = this.coverModel;
        if (saveCoverModel != null) {
            saveCoverModel.cancelHttp();
        }
        clearCache();
        super.onDestroy();
    }
}
